package com.excilys.patricksbank.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.excilys.patricksbank.model.Compte;
import com.excilys.patricksbank.model.Utilisateur;
import com.excilys.patricksbank.service.api.CompteService;

@Controller
@RequestMapping(value = "/user/")
@SessionAttributes("utilisateur")
public class UserController {

	@Resource
	private CompteService compteService;

	@RequestMapping(value = "/home.html")
	public String buildUserHome(Model model, @ModelAttribute("utilisateur") Utilisateur user) {

		List<Compte> listComptes = compteService.getComptesParUtilisateur(user);

		model.addAttribute("listComptes", listComptes);

		return "accueil";
	}

	
}
